#include"sentry.h"
Sentry::Sentry()
{
    _task = Serial::AUTO_SHOOT;
    _shootTask = Serial::ARMOR_SHOOT;
}

void Sentry::Sense()
{
    
}

void Sentry::Consume() 
{
    Mat src;
    while (1)
    {
        sem_wait(&sem_pro);
        try{
                _buffer.GetImage(src);
        }catch(...){ 
                std::cout << "读取相机图片出错" << std::endl;
                exit(-1);
        }
        sem_post(&sem_com);
        putText( src, "ARMOR_SHOOT", Point(8,40),
            FONT_HERSHEY_SIMPLEX,0.5, Scalar (80,150,80),2);
        cv::imshow("sentry",src);
        cv::waitKey(8);
        if (src.size().width != MAT_WIDTH || src.size().height != MAT_HEIGHT)
        {
            cv::waitKey(1000);
           continue;
        }
        if(!src.empty())
        {
            _workState->_shootTask = _shootTask;
            _workState->_task = _task;
            _workState->startProgram(serial,src);
        }
    }
}

shared_ptr<Phoenix> SentryFactory::creatPhoenix()
{
    return shared_ptr<Sentry>(new Sentry());
}